//
//  GYBasePopoverViewController.m
//  GoodLuck
//
//  Created by apple on 2018/3/19.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

#import "GYBasePopoverViewController.h"
#import "GYPopoverCell.h"
@interface GYBasePopoverViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation GYBasePopoverViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    self.tableView.rowHeight = 50;
}

#pragma mark -- UITableViewDelegate,UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titles.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    GYPopoverCell *cell = [GYPopoverCell cellWithTableView:tableView];
    cell.homeImage.image = [UIImage imageNamed:self.images[indexPath.row]];
    cell.homeTitleLable.text = self.titles[indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self dismissViewControllerAnimated:YES completion:^{
        self.popoverViewSelectIndexCallBack(indexPath.row);        
    }];
}

@end
